new Vue({
	el: "body",
	data: {
		name: "",
		sex: true,
		phone: "",
		address: "",
		addresslist: [],
		userid: "",
		add: false,
		loading: false,

	},
	methods: {
		addr: function() {
			if(this.name && this.phone && this.address) {

				var address = {
					name: this.name,
					sex: this.sex,
					phone: this.phone,
					address: this.address
				}
				var arr = this.addresslist;
				console.log(arr);
				arr.push(address);
				var todo = AV.Object.createWithoutData('_User', this.userid);
				// 修改属性
				todo.set('address', arr);
				// 保存到云端
				todo.save();
				history.go(-1);
			}
		},
		man: function() {
			this.sex = true;
		},
		woman: function() {
			this.sex = false;
		},
		seladd: function(index) {
			location.href = "../confirmOrder/confirmOrder.html" + location.search + "&index=" + index;
		}

	},
	created: function() {
		init();
		var currentUser = AV.User.current();
		var userid = currentUser.id;
		this.userid = userid;
		var _this = this;
		var query = new AV.Query('_User'); //用户表
		query.get(userid).then(function(user) {
			console.log(user);
			if(user.attributes.address) {
				_this.addresslist = user.attributes.address;
			}
		})

	},
	beforeCompile: function() {
		this.loading = true;
	}
})